package com.servlet.web;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @Title: RemoveAreaServlet
 * @Description:
 * @Auther: py
 * @Version: 1.0
 * @create 2023/12/26 10:22
 */
@WebServlet("/remove")
public class RemoveAreaServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();

        ServletContext servletContext = req.getServletContext();
        req.removeAttribute("userrequest");
        session.removeAttribute("usersession");
        servletContext.removeAttribute("usercontext");
        resp.getWriter().write("success!");
        // 销毁session
        // session.invalidate();
    }
}
